Skip to content

feat(engine): hand the DFlash drafter the prompt's hidden states on the hybrid prompt-cache path - #143

Merged
krcm0209 merged 3 commits into
mainfrom
claude/issue-142-j7ike6
Sep 28, 2026
Merged

krcm0209 merged 3 commits into
mainfrom
claude/issue-142-j7ike6

Conversation

@krcm0209

@krcm0209 krcm0209 commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

What and why

Closes #142.

On a hybrid model the prompt cache prefills the stable render in a drafter-less call and stops at the anchor, so the decode call — the only one that runs the drafter — prefills just the generation prompt, and mlx-vlm's DFlash round loop hands the drafter those 7 tokens as its whole context. #131 measured the cost on 64 real subagent turns at block 3: 2.27 tokens per round against 2.58 with the turn's own prefill in front of it (~+10% decode) and 2.62 with the last 2,047 tokens of the prompt.

Capture the tail of every prefill. Every segment a turn prefills before its decode now runs with a capture that PrefixCache._run threads through the fork stops. VLMEngine.prefill passes mlx-vlm's own capture_layer_ids kwarg to generate(), and a class-level post-hook on the language model's forward (armed per instance only for that call, src/sous/engine/draftctx.py) keeps the newest window of each forward's hidden states in one sink. generate_step deletes every chunk's output, so the hook is the only observer — and the prefill runs exactly as before, so the KV cache is bit-identical. The trimmable path benefits at fork stops too; a plain warm turn there is unchanged (its decode call prefills the delta itself).

Hand over the tail only. The window is the drafter's own (sliding_window - 1, 2047 on the shipped drafter), read off its config. The sink holds at most ~210 MB while a second chunk is being taken and the assembled tail ~105 MB across the decode, whatever the prompt's length; the tail is assembled as its own buffer (a slice of the chunks would be a view pinning twice its size). The decode seeds it into per-instance wraps of the drafter's draft_block, draft_block_greedy and reset, which prepend it once, on the first draft call after the round loop's reset; the drafter's sliding attention keeps the newest window of tail plus own prompt itself.

Log acceptance. The decode reads mlx-vlm's lifetime round counters before and after each call and the prompt cache assigns them as per-turn gauges on every decode path (the cache-off one included), so the turn line carries draft_rounds, drafted, accepted and draft_context beside decode_tps; the load line says draft_context=active|unavailable|off (with draft_context_window= when active) and the status document carries the reason.

Nothing here changes a token — the verify is exact — so the gates are structural (drafter kind, the hooks the round loop looks for, the layers it names, a language model that runs single tokens through its forward), not source hashes; a drift in mlx-vlm shows on the turn line as draft_context=7 (capture lost) or draft_context=0 beside unavailable on the load line (a gate tripped), never as a different reply. unload() closes the context first: the wraps close over the drafter and the drafter binds the target's embedding and head, so the weights would otherwise outlive the unload.

Not built, on purpose: the issue's optional step 4 (a stored tail beside each turn slot and fork, ~105 MB each) — a warm turn's draft_context is the delta since its previous turn plus 7, so the logged acceptance is what decides it. vlm.py is in the fork store's epoch, so every fork on disk is rebuilt once after deploy.

How you verified it

This was developed on a Linux box with a CPU build of mlx 0.32.2 (uv pip install mlx-cpu==0.32.2 into the venv, not in the lock), so the model-marked tests have not been run: the M5 Pro gate below is where that evidence comes from.

Run here on the final tree:

  • uv run ruff check . && uv run ruff format --check ., uv run ty check, uv lock --check: clean.
  • uv run pytest -m "not model": everything passes except 19 failures that fail identically on main on this box (13 in tests/test_int8prefill.py and 5 in tests/test_verifyattn.py need a Metal GPU; 1 in tests/test_forkstore.py needs a non-root user).
  • tests/test_draftctx.py (47 tests) drives the real mlx_vlm.generate, generate_step and _dflash_rounds on stub models, pinning that the capture kwarg reaches every prefill forward (2048-token chunks, then the last token), that the round loop hands the first draft after reset the prompt hidden with the seed in front and later drafts only the verify rows, that the assembled tail owns exactly its rows, that a failed capture seeds nothing, and that unload() lets go of the drafter and, through it, the language model.
  • Two agent passes over the branch: one tried to refute every assumption about mlx-vlm 0.7.2 the design rests on against the installed source (all held; two refinements applied), one reviewed the diff adversarially (every confirmed finding is fixed in this commit).

M5 Pro gate (before merge)

The issue's gate is equivalence, gain and cost on real subagent turns. On the M5 Pro, on this branch:

  1. In-tree model tests.
    uv sync
    uv run pytest -m model tests/test_engine_vlm.py -k "captured_prefill or drafts_from" -v
    
    • test_vlm_a_captured_prefill_leaves_the_cache_bit_identical_and_keeps_the_tail (Qwen3.5-9B, ~5.6 GB): the captured prefill's KV equals the uncaptured one bit for bit, and the tail equals the forward's own hidden states.
    • test_vlm_drafter_drafts_from_the_prompts_context_on_the_hybrid_path[greedy|sampled] (the default 27B and its DFlash2 drafter): draft_context past 7, rounds logged, and greedy output identical with the seeding switched off.
    • Then one served turn: uv run python scripts/api_smoke.py.
  2. Load line. After sous serve loads the model, the model_load line should read draft_context=active draft_context_window=2047. unavailable means a gate tripped; /sous/status carries the reason under draft_context.
  3. Gain, on real turns. Drive the same subagent turns as engine: measure what caps DFlash2 acceptance on subagent prompts (workload, output length, drafter window) #131 (the engine: measure whether overlapped sous-local subagents evict each other's cache before tuning decode #139/sous claude: run one subagent at a time so overlapped subagents stop evicting each other's cache #140 transcripts) or a fixed task through sous claude, and read the turn lines:
    • draft_context should be min(2047, tokens the turn prefilled + 7): ~2047 on a cold turn, the delta since the previous turn plus 7 on a warm one, never 7 while the load line says active.
    • tokens per round is (accepted + draft_rounds) / draft_rounds; expect ~2.5–2.6 at block 3 sampled on turns with a full window (against 2.27 today), and decode_tps up ~10% on those turns against the same turns on main.
  4. Equivalence. At temperature = 0, the same prompt through main and this branch must produce identical text — the in-tree greedy test covers one cold turn; engine: measure what caps DFlash2 acceptance on subagent prompts (workload, output length, drafter window) #131's harness covers the 64 real ones (it loads the engine and runs mlx-vlm's greedy round loop). [model].prompt_cache = false is the full-context reference: mlx-vlm's own path hands the drafter the whole prompt there, unchanged by this PR.
  5. Cost. prefill_s / prefill_tps on the turn line and peak memory (sous top, or memory_gb in /sous/status) should be unchanged within noise on the same turns.
  6. After the gate: re-tune the block (engine: re-measure speculative decode on the greedy path (sampler=None) and re-tune block size under it #118), as the issue says.

Checklist

  • Touched the engine layer (src/sous/engine/): ran uv run pytest -m model,
    and/or uv run python scripts/api_smoke.py — run on the M5 Pro with the gate above, on 4e84f2a and again on ac2129c; results in the comments.
  • Touched the loopback guard or the forwarder — not touched.
  • Fixing something intermittent — not applicable.
  • Commit subject follows Conventional Commits

🤖 Generated with Claude Code

https://claude.ai/code/session_0124KgiJ3Cgpgotsdk58dicH


Generated by Claude Code

…he hybrid prompt-cache path

On a hybrid model the prompt cache prefills the stable render in a
drafter-less call and stops at the anchor, so the decode call — the only
one that runs the drafter — prefills just the generation prompt, and
mlx-vlm's round loop hands the drafter those 7 tokens as its whole
context. #131 measured what that costs on 64 real subagent turns at block 3:
2.27 tokens per round against 2.58 with the turn's own prefill in front
of it (~+10% decode) and 2.62 with the last 2,047 tokens of the prompt.

Every segment a turn prefills before its decode now runs with a capture
the orchestrator threads through the fork stops: the prefill passes
mlx-vlm's own `capture_layer_ids` kwarg to generate(), and a class-level
post-hook on the language model's forward — armed per instance for the
duration of that call — keeps the newest window (sliding_window - 1, 2047
on the shipped drafter) of each forward's hidden states in one sink.
generate_step deletes every chunk's output, so the hook is the only
observer, and the prefill itself runs exactly as before, so the KV cache
is bit-identical. The decode assembles the tail — its own buffer, since a
slice of the chunks would pin twice its size across the decode — and
seeds it into per-instance wraps of the drafter's draft_block,
draft_block_greedy and reset, which prepend it once, on the first draft
call after the round loop's reset; the drafter's sliding attention keeps
the newest window of tail plus own prompt itself. A sink that fails
part-way voids itself rather than seed a tail that ends short of the
generation prompt. unload() closes the context first: the wraps close
over the drafter and the drafter binds the target's embedding and head,
so the weights would otherwise outlive the unload. Nothing here changes a
token — the verify is exact — so the gates are structural rather than
source hashes, and a drift in mlx-vlm shows on the turn line as
draft_context=7 (the capture lost) or as draft_context=0 beside
draft_context=unavailable on the load line (a gate tripped), not as a
different reply.

Acceptance is logged from now on. The decode reads mlx-vlm's lifetime
round counters before and after each call (its per-call accept_lens are
reset every round loop) and the prompt cache assigns them as per-turn
gauges on every decode path, the cache-off one included, so the turn line
carries draft_rounds, drafted, accepted and
draft_context beside decode_tps, and the load line and status document
say whether the seeding is armed and with what window.

tests/test_draftctx.py drives the real generate_step and _dflash_rounds
on stub models to pin the two contracts this rests on (a CPU mlx build
suffices); the model-marked tests check the captured prefill's cache
against an uncaptured one bit for bit on the hybrid, and the default
model's drafter context, acceptance and greedy equivalence. vlm.py is in
the fork store's epoch, so every fork on disk is rebuilt once after
deploy.

Closes #142.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0124KgiJ3Cgpgotsdk58dicH
The bound on what the assembled drafter context holds allowed the tail's
bytes plus one 16 KiB page, which is the CPU allocator's rounding; Metal
rounds a buffer up to its size class, and on macos-15 a 2004-row tail
came back as 1 MiB and failed the bound by 6 KiB. Measuring one array of
the tail's own shape the same way gives the budget the platform actually
charges, and the discriminating geometries (a chunk boundary well inside
the window) still exceed it under the naive slice-of-the-chunks assembly.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0124KgiJ3Cgpgotsdk58dicH
@krcm0209

Copy link
Copy Markdown
Owner Author

Gate results on 4e84f2a: all pass

M5 Pro (27B + DFlash2, block 3, mlx 0.32.2 / mlx-vlm 0.7.2, macOS 27.0)

Setup.

The control run. Main's turn line has no drafter counters, so the tokens-per-round baseline comes from a control: this branch with draftctx.enable patched to return an unavailable context. That is main's drafter behaviour with this PR's logging, and it reproduced #131's "prod" figure (2.27) exactly.

Step Result
1. Model tests pytest -m model tests/test_engine_vlm.py -k "captured_prefill or drafts_from": 3 passed. scripts/api_smoke.py: PASS
2. Load line draft_context=active draft_context_window=2047
3. draft_context == min(2047, prefilled_tokens + 7) on 64/64 turns in each of the three PR runs; min 121, max 2047, never 7
3. Tokens/round (pooled) sampled 2.27 → 2.53 / 2.56 (control → two PR runs); greedy 2.30 → 2.60. Per-turn mean, sampled: 2.22 → 2.63 / 2.64
3. Acceptance sampled 0.64 → 0.77 / 0.78; greedy 0.65 → 0.80
3. decode_tps (pooled) sampled main 19.10 / 18.11 → PR 20.53 / 20.49 (+10%, ABBA order); greedy 18.43 → 20.43 (+11%, same tokens)
4. Equivalence greedy main vs PR: 64/64 turns identical (content and stop reason); main vs control: 64/64
5. Cost prefill_tps sampled main 300.9 / 290.9 vs PR 298.6 / 296.6, greedy 288.1 vs 284.4 (noise); peak memory_gb main 38.01–38.14 vs PR 38.27–38.36 (+0.2–0.3 GB, in line with the ~210 MB sink)
Unload An idle unload (idle_unload_minutes = 1) takes memory_gb from 17.94 back to 0.0 on the PR, same as main

Where the gain lands. It is mostly on warm turns.

Turns Tokens/round (control → PR) Decode, greedy (main → PR)
17 cold, full window 2.40 → 2.51 19.9 → 20.2 tok/s
47 warm 2.27 → 2.63 18.0 → 20.5 tok/s

The control runs ran last and read slower on both prefill and decode (thermal or ordering), so their speeds are not used for the gain above. Their tokens/round do not depend on the hardware.

M2 (16 GB, macOS 15.5): what fits

What it cannot run.

Unit and model tests.

  • pytest -m "not model": 1536 passed, 8 skipped.
  • test_vlm_a_captured_prefill_leaves_the_cache_bit_identical_and_keeps_the_tail (9B): passed.
  • api_smoke.py: PASS.

Drafter test on the 9B. This is test_vlm_drafter_drafts_from_the_prompts_context_on_the_hybrid_path on Qwen3.5-9B with z-lab/Qwen3.5-9B-DFlash (DFlash v1, window 4095). The only change is that the window bound is read off the drafter. Greedy and sampled both pass, with draft_context=1107.

Daemon runs. 9B + that drafter on 4 of #131's code tasks × 3 turns, each 3–4K tokens.

Check Result
Load lines draft_context=active draft_context_window=4095; off without a drafter
draft_context rule holds on 12/12 turns
Greedy equivalence identical on 12/12 across main, PR, control and no-drafter
Tokens/round (control → PR) sampled 2.07 → 2.16; greedy 2.26 → 2.33
Decode flat: sampled 11.8–11.9, greedy 13.2–13.4 tok/s

The M2 gains little here for two reasons. The warm deltas in this workload are ~45 tokens, so draft_context is ~51–54 there. And the M2 is verify-bound: this drafter decodes slower than plain decode on it (~13 vs 17 tok/s), with or without this PR.

Not done

Step 6, re-tuning the block (#118), is the follow-up.

🤖 Generated with Claude Code

…first draft

The first-draft wrap prepended the whole captured tail whatever the decode
call's own rows: on the trimmable path with fork stops those rows are
everything after the last stop, so the concat copied a multi-GB hidden to
add context the drafter's sliding layers skip anyway. It now hands over at
most one window - the newest rows of the tail that fit beside the call's
own, none when those already fill it - which leaves the rows the drafter
keeps on the hybrid path unchanged. The seeding context also drops its
reference to the tail once the drafter holds it, so the ~105 MB is freed
by the first draft call rather than held for the whole decode; a capture
that voided itself is answered with None for the rest of the turn instead
of being re-armed on every later segment; and the sink attribute is seeded
on the language model at enable so the hook's per-forward read is a dict
hit rather than mlx's __getattr__ miss on every decode step.

Tests: the mlx-vlm stub patches the real module's attributes instead of
replacing sys.modules["mlx_vlm"], which made the decode-wiring tests fail
in isolation (the engine's decode imports mlx_vlm.speculative.utils, and a
stand-in that is not a package refuses that unless an earlier test had
imported it). The unloaded-engine fixture carries the context unload()
now leaves, and the prompt-cache prefill overrides default capture to None
like the protocol. Docs: the count gauges also read 0 when the drafter ran
no round, not only without a drafter.

Co-Authored-By: Claude <noreply@anthropic.com>
@krcm0209

Copy link
Copy Markdown
Owner Author

Re-gate on ac2129c: all pass

The setup is the same as the 4e84f2a gate above. CI is green on ac2129c.

Why the one-window cap changes nothing the drafter keeps on the hybrid path.

  • In mlx-vlm 0.7.2, qwen3_dflash sliding attention trims x_ctx to its newest sliding_window - 1 rows before projecting, and advances cache.offset by what it skipped. DFlash2's layers are all sliding.
  • So 2040 tail rows + 7 generation-prompt rows are the same 2047 rows as before. The only difference is RoPE positions shifted by 7, which leaves relative positions unchanged.
  • The drafter counts below match that: greedy differs from 4e84f2a by one round and two accepted tokens over 64 turns.

M5 Pro (27B + DFlash2, #131's 64 turns)

Check ac2129c 4e84f2a / main
Model tests (captured_prefill or drafts_from), api_smoke.py 3 passed, PASS —
Load line draft_context=active draft_context_window=2047 same
Greedy replies vs main 64/64 identical 64/64
Greedy rounds / drafted / accepted 2928 / 5856 / 4682 2927 / 5854 / 4684
Tokens/round: greedy / sampled 2.60 / 2.57, 2.53 2.60 / 2.53, 2.56
draft_context min 121, max 2047, 17 at 2047, never 7 same
Peak memory_gb 38.16–38.34 38.27–38.36
Idle unload 17.94 → 0.0 same

Decode speed.

  • Greedy decode was 20.75 tok/s, against 20.43 on 4e84f2a.
  • The two sampled runs read 19.1 decode / 272 prefill, against 20.5 / 297 this morning.
  • A main sampled control in the same hour read 17.1 decode / 275 prefill. The M5 was ~9% slower across the board that afternoon: WindowServer sat at ~45% CPU throughout, so the machine was in use.
  • Against that same-hour main, sampled decode is +12%, in line with the morning's +10%.

M2 (9B + z-lab/Qwen3.5-9B-DFlash, the 12-turn workload)

  • Test isolation fix: tests/test_draftctx.py run on its own now passes (55).
  • Unit and model tests:
    • pytest -m "not model": 1536 passed, 8 skipped.
    • The 9B captured-prefill test passes.
    • The 9B drafter test passes, greedy and sampled.
    • api_smoke.py: PASS.
  • Greedy daemon run: replies are identical to main and to 4e84f2a on 12/12 turns, with identical drafter counts (1415 / 2828 / 1888). No turn on this workload exceeded the 4095 window, so the cap itself was not exercised on the M2.

🤖 Generated with Claude Code

@krcm0209
krcm0209 merged commit 3deb94d into main Sep 28, 2026
9 checks passed
@krcm0209
krcm0209 deleted the claude/issue-142-j7ike6 branch September 28, 2026 20:55
This was referenced Sep 28, 2026
krcm0209 added a commit that referenced this pull request Oct 1, 2026
#145)

## What and why

Decode's one-row attention and the exact verifier's attention now run on
the M5's tensor units,
through one GQA-packed MPP tile whose key partition steps with context
(`src/sous/engine/tileattn.py`,
`src/sous/engine/kernels/attention_tile.metal`). Verify attention
is most of decode's context-dependent cost at subagent context, and the
tile cuts it 2–2.6x at
block 3. A row's output depends only on its chunk and the chunk is fixed
per 640-key step, so a
verify row is bit-identical to the one-row decode at its own key count:
greedy output with the
DFlash2 drafter stays identical to output without it.

- On by default through `[model].attention_tile`; `false` runs the stock
paths.
- Active only on the measured split target, the M5 Pro's 20 GPU cores,
with macOS 26.2+, a dense
qwen3_5 model at 24/4/256 bf16 and no drafter or a DFlash one;
`unavailable` with its reason
  everywhere else, where nothing changes.
- The model-load line gains `attention_tile=` (with
`attention_tile_splits=` and
`attention_tile_probe_s=` when active), and `/sous/status` an
`attention_tile` block.
- `sous tune` keys suite rows by the setting, so a resume never mixes
tile and stock rows.

**Refusal policy (an amendment to the design's failure policy).** The
design had every refusal
emit one `warnings.warn`. Here, a refusal that only says the tile does
not apply (the Mac's
platform, the model, the drafter's kind, the split target) logs one INFO
line and keeps
`state: unavailable` plus its reason in the status, because the tile is
on by default and most
Macs refuse it. A refusal that means the tile should have run and did
not (a pinned dependency
that drifted, the exact verifier missing beside DFlash, a compile or
probe failure, an exception)
still warns once. A model load never fails because of either.

**Fork store.** Landing this cold-starts every on-disk fork store once,
whatever the setting: the
fork key gains `tile` and `os` (the macOS product version and build),
and `tileattn.py` joins the
engine epoch. `os` is keyed always, not only while a sous kernel is
active, because the stock
path's runtime-compiled kernels also build against the OS's Metal
toolchain; so every macOS
update cold-starts every fork store once too.

**Known limitations.**
- "Off equals main" rests on this gate's check (64/64 greedy replies and
cache histories, below).
- `sous tune` bench rows are not keyed by the setting (int8 prefill has
the same gap): a `--resume`
across a flip of `attention_tile` can reuse bench decode rows measured
under the other setting.
- The lock pins mlx 0.32.2, the only version in `VALIDATED_MLX`. mlx
0.32.3 is released and not
validated: a fresh install that resolves it runs the stock attention
paths, with verifyattn's
warning and the tile's own, until the pin is extended and the tile's
exactness and timing tests
  are re-run.

**What the gate measured.** Every figure below is from commit c532cac,
against main at 5db92d5;
the one commit after it, a7e004c, only updates the README's and
`docs/configuration.md`'s decode
figures from this gate (1.21x pooled; 32–64K ratio 1.20, so about 23.5
tok/s at 57K and Splash's
lead at 51–57K down to an estimated 1.4–1.6x). A first gate attempt at
014e1dc failed the
kernel-timing criterion and was stopped there: `tile()` redid the kernel
sources' text work on
every launch, which cost ~4–5 µs per call and made the in-tree entry
4–7% slower than the spike's
kernel at 2–8K keys (output bitwise identical). c532cac builds the
kernel pair once per process;
this gate re-ran every step at c532cac. Expected refusals no longer warn
as of 3a076c6, which is
also in this gate's commit: the M2 Air's load logs `attention tile
unavailable: macOS 15.5 < 26.2`
at INFO and no warning.

**One greedy loop, reported.** The only max_tokens stops in the gate's
replay runs are greedy, on
one turn, and in this gate they are tile-specific. On a442f184#3 (68K):
- all three branch greedy runs (tile-g to 1,024 tokens; t-d-g and t-nd-g
to 256) repeat
  `def _store_|` inside a Grep pattern up to the cap;
- all three stock greedy runs (main-g, main-g256 and off-g256) return
the same 123-token Grep call.

The two paths split at a near-tie at token 20, where the tile's last-bit
differences pick the
other token, and greedy then loops, with the drafter on or off. No
sampled run (the shipped
setting) hit max_tokens, and the tool-loop suite logged no repetition on
either arm. In the
spike's earlier greedy runs, from another cache state, stock also looped
on this turn. This
matters if greedy becomes the default (#87).

**Kernel-timing ruling.** The spec's kernel-timing criterion asks for
the in-tree / spike median
ratio within 0.97–1.03 and the speedup over stock or grouped within 5%
of the spike's table. At
c532cac the in-tree / spike ratio is 0.993–1.028 in all 15 cells, output
bitwise identical, and
14 cells are within 5% of the table. The 15th, 262K keys at T = 3,
measured 2.83x against the
table's 2.56x: faster than the table, because stock's grouped baseline
varies run to run at that
size. Ruled for this gate: the band is read one-sided (a failure only
when the speedup falls
more than 5% below the table), and the binding codegen check is the
same-process in-tree / spike
ratio. The three M5 measurements of that cell during the gate:

| run | grouped ms | tile ms | speedup |
|---|---|---|---|
| 014e1dc | 185.4 | 66.2 | 2.80x |
| 014e1dc, kernel pair cached (diagnostic) | 149.2 | 59.6 | 2.50x |
| c532cac | 196.1 | 69.3 | 2.83x |
| spike's table | 160.99 | 62.87 | 2.56x |

Spec: `docs/superpowers/specs/2026-09-30-attention-tile-design.md`.
Plan:
`docs/superpowers/plans/2026-09-30-attention-tile.md`.

Issue: #132. Still open and out of scope: block 8 and cheaper verify
projections, #126 and #133.

## Merge gate (M5 Pro, 20 GPU cores)

At c532cac on the M5: `pytest -m "not model"` 1810 passed, none skipped
(the tile's `nax` tests included); `pytest -m model` on the tile and
verifyattn model tests, 2 passed (real 27B).

### Load

~~~
2026-09-30T21:40:59.318Z INFO sous.engine: model_load seconds=3.7
model=mlx-community/Qwen3.8-27B-4bit positions=engine
verify_attention=active verify_attention_probe_s=0.48
draft_context=active draft_context_window=2047 attention_tile=active
attention_tile_splits=20 attention_tile_probe_s=0.16
2026-09-30T23:42:52.392Z INFO sous.engine: model_load seconds=2.9
model=mlx-community/Qwen3.8-27B-4bit positions=engine
verify_attention=off draft_context=off attention_tile=active
attention_tile_splits=20 attention_tile_probe_s=0.2
2026-10-01T01:54:20.528Z INFO sous.engine: model_load seconds=3.5
model=mlx-community/Qwen3.8-27B-4bit positions=engine
verify_attention=active verify_attention_probe_s=0.47
draft_context=active draft_context_window=2047 attention_tile=off
2026-09-30T21:18:25.859Z INFO sous.engine: model_load seconds=4.4
model=mlx-community/Qwen3.8-27B-4bit positions=engine
verify_attention=active verify_attention_probe_s=0.52
draft_context=active draft_context_window=2047
~~~

### Path (process totals per branch run)

~~~
tile-s1: PASS state=active {'decode_tile': 2128, 'verify_calls': 52592,
'verify_rows_tile': 157776, 'verify_launches': 52768,
'verify_straddles': 176, 'verify_t3': 52592}
tile-s2: PASS state=active {'decode_tile': 2128, 'verify_calls': 53280,
'verify_rows_tile': 159840, 'verify_launches': 53504,
'verify_straddles': 224, 'verify_t3': 53280}
tile-g: PASS state=active {'decode_tile': 2128, 'verify_calls': 52544,
'verify_rows_tile': 157616, 'verify_launches': 52736,
'verify_straddles': 192, 'verify_t2': 16, 'verify_t3': 52528}
tile-nd1: PASS state=active {'decode_tile': 21792}
tile-nd2: PASS state=active {'decode_tile': 23520}
t-d-g: PASS state=active {'decode_tile': 816, 'verify_calls': 11904,
'verify_rows_tile': 35712, 'verify_launches': 11936, 'verify_straddles':
32, 'verify_t3': 11904}
t-nd-g: PASS state=active {'decode_tile': 34144}
off-g256: PASS state=off {}
~~~

### Decode, sampled ABBA on the 64 turns

| run | temp | turns | out tok | decode tok/s | tok/round |
accepted/drafted | prefill tok/s | prefilled | misses | pressure | peak
mem GB | total s | draft_context min..max | tile counters |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| main-s1 | 0.7 | 64 | 8401 | 19.28 | 2.564 | 5107/6530 = 0.782 | 284.3
| 257235 | 2 | 0 | 37.85 | 1352 | 121..2047 | - |
| tile-s1 | 0.7 | 64 | 8471 | 23.58 | 2.566 | 5148/6574 = 0.783 | 284.4
| 257235 | 2 | 0 | 37.85 | 1275 | 121..2047 | decode_tile=2128
verify_calls=52592 verify_rows_tile=157776 verify_launches=52768
verify_straddles=176 verify_t3=52592 |
| tile-s2 | 0.7 | 64 | 8461 | 23.33 | 2.532 | 5100/6660 = 0.766 | 284.6
| 257235 | 2 | 0 | 37.95 | 1277 | 121..2047 | decode_tile=2128
verify_calls=53280 verify_rows_tile=159840 verify_launches=53504
verify_straddles=224 verify_t3=53280 |
| main-s2 | 0.7 | 64 | 8107 | 19.49 | 2.572 | 4932/6274 = 0.786 | 286.5
| 257235 | 2 | 0 | 37.78 | 1325 | 121..2047 | - |
| main-g | 0.0 | 64 | 7642 | 20.07 | 2.599 | 4682/5856 = 0.800 | 286.2 |
257235 | 2 | 0 | 37.91 | 1290 | 121..2047 | - |
| tile-g | 0.0 | 64 | 8651 | 24.52 | 2.624 | 5334/6567 = 0.812 | 285.3 |
257235 | 2 | 1 | 37.86 | 1265 | 121..2047 | decode_tile=2128
verify_calls=52544 verify_rows_tile=157616 verify_launches=52736
verify_straddles=192 verify_t2=16 verify_t3=52528 |
| main-nd1 | 0.7 | 16 | 1222 | 12.51 | - | 0/0 = - | 296.6 | 228118 | 2
| 0 | 38.77 | 872 | 0..0 | - |
| tile-nd1 | 0.7 | 16 | 1326 | 13.13 | - | 0/0 = - | 295.7 | 228118 | 2
| 0 | 38.59 | 877 | 0..0 | decode_tile=21792 |
| tile-nd2 | 0.7 | 16 | 1434 | 13.17 | - | 0/0 = - | 295.9 | 228118 | 2
| 0 | 38.70 | 885 | 0..0 | decode_tile=23520 |
| main-nd2 | 0.7 | 16 | 1570 | 12.63 | - | 0/0 = - | 295.1 | 228118 | 2
| 0 | 38.72 | 902 | 0..0 | - |

Per bucket (pooled decode tok/s; turns / output tokens):
| run | <32K | 32-64K | 64-128K | >=128K |
|---|---|---|---|---|
| main-s1 | - | 19.57 (48 / 5881; tpr 2.55) | 18.63 (16 / 2520; tpr
2.60) | - |
| tile-s1 | - | 23.93 (48 / 6247; tpr 2.58) | 22.65 (16 / 2224; tpr
2.52) | - |
| tile-s2 | - | 23.51 (48 / 6270; tpr 2.53) | 22.82 (16 / 2191; tpr
2.54) | - |
| main-s2 | - | 19.89 (48 / 5823; tpr 2.57) | 18.54 (16 / 2284; tpr
2.57) | - |
| main-g | - | 20.46 (48 / 5684; tpr 2.60) | 19.01 (16 / 1958; tpr 2.60)
| - |
| tile-g | - | 24.40 (48 / 5805; tpr 2.59) | 24.77 (16 / 2846; tpr 2.70)
| - |
| main-nd1 | - | 12.79 (10 / 812; tpr -) | 11.99 (6 / 410; tpr -) | - |
| tile-nd1 | - | 13.30 (10 / 710; tpr -) | 12.94 (6 / 616; tpr -) | - |
| tile-nd2 | - | 13.41 (10 / 870; tpr -) | 12.82 (6 / 564; tpr -) | - |
| main-nd2 | - | 12.91 (10 / 1052; tpr -) | 12.10 (6 / 518; tpr -) | - |
pairs tile-s1/main-s1, tile-s2/main-s2: 128 turn pairs
| bucket | turn pairs | tile out / decode s | main out / decode s | tile
tok/s | main tok/s | ratio | 95% CI (turn bootstrap) | median per-turn
ratio (turns >= 50 tok both) | tile tok/round | main tok/round | tile
acc rate | main acc rate | tile prefill tok/s | main prefill tok/s |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| all | 128 | 16932 / 722.0 | 16508 / 851.8 | 23.45 | 19.38 | **1.210**
| 1.192–1.226 | 1.216 (n=116) | 2.549 | 2.568 | 0.774 | 0.784 | 284.5 |
285.4 |
| >=32K | 128 | 16932 / 722.0 | 16508 / 851.8 | 23.45 | 19.38 |
**1.210** | 1.192–1.226 | 1.216 (n=116) | 2.549 | 2.568 | 0.774 | 0.784
| 284.5 | 285.4 |
| <32K | 0 | | | | | | | | | | | | | |
| 32-64K | 96 | 12517 / 527.8 | 11704 / 593.3 | 23.72 | 19.73 |
**1.202** | 1.180–1.223 | 1.212 (n=88) | 2.554 | 2.561 | 0.777 | 0.780 |
293.1 | 294.1 |
| 64-128K | 32 | 4415 / 194.2 | 4804 / 258.5 | 22.73 | 18.58 | **1.223**
| 1.198–1.245 | 1.221 (n=28) | 2.534 | 2.587 | 0.767 | 0.793 | 245.8 |
246.1 |
| >=128K | 0 | | | | | | | | | | | | | |

tokens/round tile − main: -0.019 (95% CI -0.059..0.016)
peak memory_gb over these turns: tile 37.95, main 37.85

### Greedy, identical-output turns only

~~~
a442f184#11 n= 77348 out= 12/ 12 same=1 decode_s tile-g= 0.8 main-g= 1.0
tps 14.9/ 11.9 main/tile time=1.25 rounds 4/4
44-77K: 46 identical turns, 4590 tokens: tile-g 25.39 tok/s, main-g
21.08 tok/s, speedup 1.204x
~~~

### max_tokens stops, branch against main on the same turn

~~~
tile-g vs main-g a442f184#3 n=68427: stop max_tokens/tool_use, out
1024/123
done
~~~

### Drafter off, sampled ABBA on 16 turns

pairs tile-nd1/main-nd1, tile-nd2/main-nd2: 32 turn pairs
| bucket | turn pairs | tile out / decode s | main out / decode s | tile
tok/s | main tok/s | ratio | 95% CI (turn bootstrap) | median per-turn
ratio (turns >= 50 tok both) | tile tok/round | main tok/round | tile
acc rate | main acc rate | tile prefill tok/s | main prefill tok/s |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| all | 32 | 2760 / 209.9 | 2792 / 222.0 | 13.15 | 12.58 | **1.046** |
1.037–1.054 | 1.046 (n=21) | - | - | - | - | 295.8 | 295.9 |
| >=32K | 32 | 2760 / 209.9 | 2792 / 222.0 | 13.15 | 12.58 | **1.046** |
1.037–1.054 | 1.046 (n=21) | - | - | - | - | 295.8 | 295.9 |
| <32K | 0 | | | | | | | | | | | | | |
| 32-64K | 20 | 1580 / 118.3 | 1864 / 145.0 | 13.36 | 12.86 | **1.039**
| 1.031–1.044 | 1.042 (n=13) | - | - | - | - | 311.0 | 311.0 |
| 64-128K | 12 | 1180 / 91.6 | 928 / 77.0 | 12.88 | 12.05 | **1.069** |
1.050–1.083 | 1.068 (n=8) | - | - | - | - | 262.8 | 263.0 |
| >=128K | 0 | | | | | | | | | | | | | |

### Parity: drafter on against off, greedy, 23 turns to 228,630 tokens

~~~
equivalence t-d-g vs t-nd-g: 23/23 identical; cache histories equal on
23/23
~~~

### attention_tile = false against main, greedy, 64 turns

~~~
equivalence off-g256 vs main-g256: 64/64 identical; cache histories
equal on 64/64
~~~

### Tool-loop suite, 8 tasks x 6 runs per arm

| task | stock grades | stock mean | tile grades | tile mean | stock s
(mean) | tile s (mean) | stock out tok (mean) | tile out tok (mean) |
stock turns (mean) | tile turns (mean) |
|---|---|---|---|---|---|---|---|---|---|---|
| cli_flag | 1 1 1 1 1 0.67 | 0.944 | 1 1 1 1 1 1 | 1.000 | 28.6 | 28.8
| 687 | 694 | 5.0 | 4.8 |
| dataclass_from_schema | 1 1 1 1 1 0 | 0.833 | 1 1 1 1 1 1 | 1.000 |
31.9 | 33.1 | 786 | 804 | 5.5 | 5.8 |
| docstring_sweep | 1 1 1 1 1 1 | 1.000 | 1 1 1 1 1 1 | 1.000 | 26.6 |
27.0 | 645 | 645 | 4.5 | 4.5 |
| fix_intervals | 1 1 1 1 1 1 | 1.000 | 1 1 1 1 1 1 | 1.000 | 13.1 |
13.4 | 251 | 249 | 3.2 | 3.3 |
| implement_rpn | 1 1 1 1 1 1 | 1.000 | 1 1 1 1 1 1 | 1.000 | 33.2 |
34.7 | 832 | 846 | 4.0 | 4.5 |
| migrate_config | 1 1 1 1 1 1 | 1.000 | 1 1 0.67 1 1 1 | 0.944 | 28.7 |
28.9 | 722 | 717 | 4.3 | 4.2 |
| rename_symbol | 1 1 1 1 1 1 | 1.000 | 1 1 1 1 1 1 | 1.000 | 30.0 |
30.3 | 736 | 730 | 5.7 | 5.3 |
| tests_for_slugify | 1 0 1 1 1 1 | 0.833 | 1 1 1 1 1 1 | 1.000 | 26.9 |
20.0 | 628 | 464 | 5.5 | 3.5 |

| arm | runs | mean grade | perfect runs | failed/error states | task
seconds total | output tokens | out tok / task s | malformed |
repetitions |
|---|---|---|---|---|---|---|---|---|---|
| stock | 48 | 0.951 | 45 | 0 | 1314 | 31724 | 24.13 | 0 | 0 |
| tile | 48 | 0.993 | 47 | 0 | 1298 | 30900 | 23.81 | 0 | 0 |

Per round (mean grade; task seconds):
| round | stock grade | stock s | tile grade | tile s |
|---|---|---|---|---|
| 0 | 1.000 | 179 | 1.000 | 212 |
| 1 | 0.875 | 243 | 1.000 | 215 |
| 2 | 1.000 | 215 | 0.958 | 209 |
| 3 | 1.000 | 224 | 1.000 | 212 |
| 4 | 1.000 | 225 | 1.000 | 216 |
| 5 | 0.833 | 228 | 1.000 | 234 |

Tile counters per arm (sum of per-run deltas; per attention call):
- stock: switch={False} state={'off'} verifyattn_grouped=181760
- tile: switch={True} state={'active'} decode_stock=1728
decode_tile=5184 verify_calls=178032 verify_launches=140944
verify_rows_stock=113024 verify_rows_tile=421072 verify_straddles=784
verify_t3=178032

The one imperfect tile run (migrate_config, 2/3) and the four imperfect
stock runs share their failure mode: well-formed code with a logic slip,
after the suite's allowlist refused the model's own check, or a turn
budget run out; no garbled output, malformed call or repetition on
either arm.

### Kernel timings, ms per 16-layer chain

The one FAIL cell is 262K at T = 3, faster than the table; it passes
under the one-sided ruling above.

| ctx | T | baseline | baseline ms | tree ms | spike ms | A/A gap | tree
/ spike | speedup | spec speedup | tree == spike | cell |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 2048 | 1 | stock | 1.168 | 1.058 | 1.029 | +1.1% | 1.028 | 1.10x |
1.11x | True | ok |
| 2048 | 3 | grouped | 2.099 | 1.113 | 1.109 | +0.0% | 1.004 | 1.89x |
1.90x | True | ok |
| 2048 | 8 | grouped | 4.788 | 1.582 | 1.578 | +0.1% | 1.002 | 3.03x |
2.95x | True | ok |
| 8192 | 1 | stock | 2.849 | 2.403 | 2.389 | +0.2% | 1.006 | 1.19x |
1.18x | True | ok |
| 8192 | 3 | grouped | 5.686 | 2.546 | 2.538 | +0.1% | 1.003 | 2.23x |
2.20x | True | ok |
| 8192 | 8 | grouped | 14.301 | 3.674 | 3.658 | +0.4% | 1.004 | 3.89x |
3.98x | True | ok |
| 57000 | 1 | stock | 15.429 | 13.221 | 13.238 | +0.1% | 0.999 | 1.17x |
1.16x | True | ok |
| 57000 | 3 | grouped | 32.152 | 13.633 | 13.671 | +0.1% | 0.997 | 2.36x
| 2.33x | True | ok |
| 57000 | 8 | grouped | 81.512 | 20.447 | 20.528 | -0.2% | 0.996 | 3.99x
| 3.98x | True | ok |
| 131072 | 1 | stock | 34.295 | 29.473 | 29.551 | -0.2% | 0.997 | 1.16x
| 1.15x | True | ok |
| 131072 | 3 | grouped | 73.412 | 30.188 | 30.143 | -0.0% | 1.001 |
2.43x | 2.41x | True | ok |
| 131072 | 8 | grouped | 217.832 | 52.844 | 52.151 | -0.1% | 1.013 |
4.12x | 4.09x | True | ok |
| 262136 | 1 | stock | 69.387 | 58.368 | 58.312 | +0.2% | 1.001 | 1.19x
| 1.19x | True | ok |
| 262136 | 3 | grouped | 196.072 | 69.336 | 69.808 | +0.4% | 0.993 |
2.83x | 2.56x | True | FAIL |
| 262136 | 8 | grouped | 453.706 | 104.030 | 103.360 | +1.3% | 1.006 |
4.36x | 4.25x | True | ok |
ktime FAIL (1 cells)

### M2 Air (9B + DFlash, the #143 task set)

~~~
HTTP errors: 0
greedy replies identical on 12/12 turns
branch load line: sous.engine: model_load seconds=8.2
model=mlx-community/Qwen3.5-9B-MLX-4bit positions=engine
verify_attention=active verify_attention_probe_s=0.21
draft_context=active draft_context_window=4095
attention_tile=unavailable
branch attention_tile: {'state': 'unavailable', 'reason': 'macOS 15.5 <
26.2'}
~~~

`scripts/api_smoke.py`: M5 `PASS: a tool_use block came back`, M2 `PASS:
a tool_use block came back`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
krcm0209 added a commit that referenced this pull request Oct 4, 2026
…oup kernel (#155)

## What and why

The default 27B's small-row quantized projections now run through a
simdgroup MMA kernel ported
from the Splash spike (`src/sous/engine/projkernel.py`,
`src/sous/engine/kernels/projection_mma.{h,metal}`): every DFlash verify
forward, and every target
call of up to 8 rows outside the verifier, decode included. mlx-vlm's
exact verifier keeps each
row bitwise equal to one-row decode, but its projection cost climbs with
rows; the kernel's stays
nearly flat from 1 to 8 rows, which makes verify block 5 pay. Its rows
are bitwise independent of
the row count and of which linears share a dispatch, so a verify row
equals the decode of the same
token, and greedy output with the DFlash2 drafter stays identical to
output without it.

- On by default through `[model].projection_kernel`; `false` runs
today's paths.
- Active only where the attention tile is active (the M5 Pro), on the
default dense qwen3_5 4-bit
model with no drafter or a DFlash one; `unavailable` with its reason
everywhere else, where
  nothing changes.
- An unset `[model].speculative_block_size` now resolves to 5 where the
kernel is active and to 4
  elsewhere; an explicit value always wins, and 0 keeps its meaning.
- The cost: decode without a drafter must take the kernel too, for
greedy parity, and runs slower
  where the kernel is active (measured below).
- The model-load line gains `projection_kernel=` (with
`projection_kernel_probe_s=` when active)
and `draft_block=`, and `/sous/status` a `projection_kernel` block and
`draft_block`.
- `sous tune` keys suite rows by the setting, pins each block arm's
block explicitly, and marks
  the current arm by the block the engine would resolve.
- THIRD_PARTY_NOTICES.md gains a Splash section (Apache-2.0).

**Fork store.** Landing this cold-starts every on-disk fork store once,
including stores with the
kernel off: the fork key gains `proj`, and `projkernel.py` joins the
engine epoch.

**Configs with an explicit block.** A config that sets
`speculative_block_size = 4` (the
documented example used to) keeps block 4; remove the line to let the
engine choose 5.

**Departures from the spec, decided during review and the gate:**
- A target that grows `speculative_verify_dflash_hidden` is refused with
a warning rather than
at INFO: on qwen3_5 with a DFlash drafter it can only come from an
mlx-vlm change, which is the
kind of drift the refusal rules say must warn. The pins also cover
`_dflash_rounds`,
`Qwen3_5DecoderLayer.__call__` and the verifier's `_layer`, which decide
that greedy verify and
  decode reach the hooks.
- Kernel timings: one cell of 96 fell outside the ±3% band, k/v at T =
1, with the in-tree
kernel 3.0% *faster* than the spike (A/A 0.1%; outputs bitwise equal;
every per-forward row
within ±2%). It was read one-sided, as #132's gate read its tile
timings: the band guards the
port against running slower than the speed evidence it inherits.
`ktime.py` itself prints FAIL
  for it below.

Spec: `docs/superpowers/specs/2026-10-03-projection-kernel-design.md`.
Plan:
`docs/superpowers/plans/2026-10-03-projection-kernel.md`.

Issue: #148. Still open and out of scope: block 6, and the suite's
per-arm project paths (#149).

## Merge gate (M5 Pro, 20 GPU cores)

### Load

~~~
sous.engine: model_load seconds=3.8 model=mlx-community/Qwen3.8-27B-4bit
positions=engine verify_attention=active verify_attention_probe_s=0.48
draft_context=active draft_context_window=2047 attention_tile=active
attention_tile_splits=20 attention_tile_probe_s=0.16
projection_kernel=active projection_kernel_probe_s=0.19 draft_block=5
sous.engine: model_load seconds=2.7 model=mlx-community/Qwen3.8-27B-4bit
positions=engine verify_attention=off draft_context=off
attention_tile=active attention_tile_splits=20
attention_tile_probe_s=0.2 projection_kernel=active
projection_kernel_probe_s=0.18
sous.engine: model_load seconds=2.9 model=mlx-community/Qwen3.8-27B-4bit
positions=engine verify_attention=active verify_attention_probe_s=0.48
draft_context=active draft_context_window=2047 attention_tile=active
attention_tile_splits=20 attention_tile_probe_s=0.15
projection_kernel=off draft_block=4
sous.engine: model_load seconds=4.3 model=mlx-community/Qwen3.8-27B-4bit
positions=engine verify_attention=active verify_attention_probe_s=0.49
draft_context=active draft_context_window=2047 attention_tile=active
attention_tile_splits=20 attention_tile_probe_s=0.16
loadtime mode=plain enable_s=5.158 state=active reason=None probe_s=5.15
draft_block=5 load_s=9.70
loadtime mode=off enable_s=0.000 state=off reason=None probe_s=None
draft_block=4 load_s=3.22
loadtime mode=cold enable_s=3.424 state=active reason=None probe_s=3.42
draft_block=5 load_s=6.29
loadtime mode=warm enable_s=0.195 state=active reason=None probe_s=0.19
draft_block=5 load_s=3.00
added by the kernel: cold 3.42 s (bound 10), warm 0.20 s (bound 1),
first load after install 5.16 s (bound 10)
loadtime: PASS
~~~

### Port equals spike: real 27B weights, every dispatch key, T = 1..8

~~~
applegpu_g17s mlx 0.32.2
q+k+v layer 3 q_proj+k_proj+v_proj T=1..8 = = = = = = = =
q+k+v layer 63 q_proj+k_proj+v_proj T=1..8 = = = = = = = =
gate+up layer 3 gate_proj+up_proj T=1..8 = = = = = = = =
gate+up layer 62 gate_proj+up_proj T=1..8 = = = = = = = =
qkv+z+b+a layer 0 in_proj_qkv+in_proj_z+in_proj_b+in_proj_a T=1..8 = = =
= = = = =
qkv+z+b+a layer 62 in_proj_qkv+in_proj_z+in_proj_b+in_proj_a T=1..8 = =
= = = = = =
o/out_proj layer 3 o_proj T=1..8 = = = = = = = =
o/out_proj layer 63 o_proj T=1..8 = = = = = = = =
o/out_proj layer 0 out_proj T=1..8 = = = = = = = =
o/out_proj layer 62 out_proj T=1..8 = = = = = = = =
down layer 3 down_proj T=1..8 = = = = = = = =
down layer 62 down_proj T=1..8 = = = = = = = =
lm_head layer - lm_head T=1..8 = = = = = = = =
q layer 3 q_proj T=1..8 = = = = = = = =
q layer 63 q_proj T=1..8 = = = = = = = =
k/v layer 3 k_proj T=1..8 = = = = = = = =
k/v layer 3 v_proj T=1..8 = = = = = = = =
k/v layer 63 k_proj T=1..8 = = = = = = = =
k/v layer 63 v_proj T=1..8 = = = = = = = =
gate/up layer 3 gate_proj T=1..8 = = = = = = = =
gate/up layer 3 up_proj T=1..8 = = = = = = = =
gate/up layer 62 gate_proj T=1..8 = = = = = = = =
gate/up layer 62 up_proj T=1..8 = = = = = = = =
in_proj_qkv layer 0 in_proj_qkv T=1..8 = = = = = = = =
in_proj_qkv layer 62 in_proj_qkv T=1..8 = = = = = = = =
z layer 0 in_proj_z T=1..8 = = = = = = = =
z layer 62 in_proj_z T=1..8 = = = = = = = =
b/a layer 0 in_proj_b T=1..8 = = = = = = = =
b/a layer 0 in_proj_a T=1..8 = = = = = = = =
b/a layer 62 in_proj_b T=1..8 = = = = = = = =
b/a layer 62 in_proj_a T=1..8 = = = = = = = =
31 dispatches x T = 1..8
PORT == SPIKE
synthetic weights, each variant forced: PORT == SPIKE, bitwise
~~~

### Path (process totals per branch run)

~~~
br-s1 (drafted): ok state=active {'verify_kernel': 744786,
'verify_split': 0, 'plain_kernel': 100807, 'declined': 0}
br-s2 (drafted): ok state=active {'verify_kernel': 685419,
'verify_split': 0, 'plain_kernel': 100576, 'declined': 0}
arms-1 (drafted): ok state=active {'verify_kernel': 398607,
'verify_split': 0, 'plain_kernel': 99460, 'declined': 0}
arms-2 (drafted): ok state=active {'verify_kernel': 398607,
'verify_split': 0, 'plain_kernel': 99460, 'declined': 0}
br-nd1 (nodraft): ok state=active {'verify_kernel': 0, 'verify_split':
0, 'plain_kernel': 864780, 'declined': 0}
br-nd2 (nodraft): ok state=active {'verify_kernel': 0, 'verify_split':
0, 'plain_kernel': 1129184, 'declined': 0}
t-d-g (drafted): ok state=active {'verify_kernel': 507832,
'verify_split': 0, 'plain_kernel': 105861, 'declined': 0}
t-nd-g (nodraft): ok state=active {'verify_kernel': 0, 'verify_split':
0, 'plain_kernel': 3763781, 'declined': 0}
off-g256 (off): ok state=off {'verify_kernel': 0, 'verify_split': 0,
'plain_kernel': 0, 'declined': 0}
path: PASS
~~~

### Speed, primary: 4v against 5k drawn per round in one branch process,
two sampled seeds

~~~
PRIMARY (pre-registered; sampled; tok/s (dt-attr, strat) vs block 4v,
95% bootstrap CI over 64 distinct turns, files paired by turn, 4000
resamples)
  5k/4v: 1.1091 [1.0814, 1.1438]
  best block (argmax of the point estimate): 5k  (28.99 tok/s adjusted)

DECISION (rule fixed before the run)
speed bar (sampled): 5k/4v 1.1091 [1.0814, 1.1438] vs >= 1.05 with CI
lower > 1.00 -> PASS
5k/4v 1.1091 [1.0814, 1.1438]: pass at >= 1.05 with the CI's lower bound
> 1.00
arms: PASS
~~~

### Speed, secondary: sampled ABBA on the 64 turns, each tree at its
default

| run | temp | turns | out tok | decode tok/s | tok/round |
accepted/drafted | prefill tok/s | prefilled | misses | pressure | peak
mem GB | total s | draft_context min..max | tile counters |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| main-s1 | 0.7 | 64 | 8997 | 26.15 | 3.067 | 6047/8778 = 0.689 | 296.6
| 257235 | 2 | 1 | 37.86 | 1223 | 121..2047 | - |
| br-s1 | 0.7 | 64 | 9727 | 27.18 | 3.350 | 6811/11592 = 0.588 | 290.0 |
257235 | 2 | 1 | 37.85 | 1256 | 121..2047 | decode_tile=2128
verify_calls=46368 verify_rows_tile=231840 verify_launches=46656
verify_straddles=288 verify_t5=46368 proj_verify_kernel=744786
proj_plain_kernel=100807 |
| br-s2 | 0.7 | 64 | 9027 | 27.26 | 3.380 | 6348/10668 = 0.595 | 289.1 |
257235 | 2 | 0 | 37.90 | 1232 | 121..2047 | decode_tile=2128
verify_calls=42672 verify_rows_tile=213360 verify_launches=42992
verify_straddles=320 verify_t5=42672 proj_verify_kernel=685419
proj_plain_kernel=100576 |
| main-s2 | 0.7 | 64 | 9127 | 24.87 | 2.987 | 6049/9135 = 0.662 | 289.6
| 257814 | 2 | 1 | 37.89 | 1269 | 121..2047 | - |
| main-nd1 | 0.7 | 16 | 1684 | 13.48 | - | 0/0 = - | 316.6 | 60753 | 1 |
0 | 32.98 | 322 | 0..0 | - |
| br-nd1 | 0.7 | 16 | 1690 | 10.56 | - | 0/0 = - | 319.1 | 60753 | 1 | 0
| 33.04 | 355 | 0..0 | decode_tile=27584 proj_plain_kernel=864780 |
| br-nd2 | 0.7 | 16 | 2222 | 10.64 | - | 0/0 = - | 325.8 | 60753 | 1 | 0
| 32.96 | 400 | 0..0 | decode_tile=36096 proj_plain_kernel=1129184 |
| main-nd2 | 0.7 | 16 | 1722 | 13.47 | - | 0/0 = - | 323.0 | 60753 | 1 |
0 | 32.98 | 320 | 0..0 | - |

Per bucket (pooled decode tok/s; turns / output tokens):
| run | <32K | 32-64K | 64-128K | >=128K |
|---|---|---|---|---|
| main-s1 | - | 26.36 (48 / 6520; tpr 3.06) | 25.59 (16 / 2477; tpr
3.08) | - |
| br-s1 | - | 27.28 (48 / 7444; tpr 3.33) | 26.86 (16 / 2283; tpr 3.42)
| - |
| br-s2 | - | 27.70 (48 / 6453; tpr 3.40) | 26.21 (16 / 2574; tpr 3.34)
| - |
| main-s2 | - | 25.00 (48 / 7270; tpr 2.97) | 24.37 (16 / 1857; tpr
3.05) | - |
| main-nd1 | - | 13.48 (16 / 1684; tpr -) | - | - |
| br-nd1 | - | 10.56 (16 / 1690; tpr -) | - | - |
| br-nd2 | - | 10.64 (16 / 2222; tpr -) | - | - |
| main-nd2 | - | 13.47 (16 / 1722; tpr -) | - | - |
pairs br-s1/main-s1, br-s2/main-s2: 128 turn pairs
| bucket | turn pairs | tile out / decode s | main out / decode s | tile
tok/s | main tok/s | ratio | 95% CI (turn bootstrap) | median per-turn
ratio (turns >= 50 tok both) | tile tok/round | main tok/round | tile
acc rate | main acc rate | tile prefill tok/s | main prefill tok/s |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| all | 128 | 18754 / 689.1 | 18124 / 711.1 | 27.22 | 25.49 | **1.068**
| 1.029–1.113 | 1.100 (n=116) | 3.365 | 3.026 | 0.591 | 0.675 | 289.5 |
293.1 |
| >=32K | 128 | 18754 / 689.1 | 18124 / 711.1 | 27.22 | 25.49 |
**1.068** | 1.029–1.113 | 1.100 (n=116) | 3.365 | 3.026 | 0.591 | 0.675
| 289.5 | 293.1 |
| <32K | 0 | | | | | | | | | | | | | |
| 32-64K | 96 | 13897 / 505.9 | 13790 / 538.1 | 27.47 | 25.63 |
**1.072** | 1.039–1.117 | 1.105 (n=88) | 3.360 | 3.013 | 0.590 | 0.671 |
298.5 | 302.4 |
| 64-128K | 32 | 4857 / 183.2 | 4334 / 173.0 | 26.51 | 25.05 | **1.058**
| 0.956–1.193 | 1.085 (n=28) | 3.378 | 3.067 | 0.595 | 0.689 | 249.2 |
251.4 |
| >=128K | 0 | | | | | | | | | | | | | |

tokens/round tile − main: 0.339 (95% CI 0.209..0.499)
peak memory_gb over these turns: tile 37.90, main 37.89

~~~
all: branch/main 1.068 (95% CI 1.029-1.113); bar >= 1.00
prefill 289.5 vs 293.1 tok/s (-1.2%; bound ±3%), peak memory 37.90 vs
37.89 GB (bound ±0.2)
abba: PASS
greedy, identical-output turns with >= 50 tokens: 45 of 64, 4688 tokens:
t-d-g 30.66 tok/s, main-g256 27.82 tok/s, 1.102x
~~~

### Drafter off, sampled ABBA on the first 16 turns

pairs br-nd1/main-nd1, br-nd2/main-nd2: 32 turn pairs
| bucket | turn pairs | tile out / decode s | main out / decode s | tile
tok/s | main tok/s | ratio | 95% CI (turn bootstrap) | median per-turn
ratio (turns >= 50 tok both) | tile tok/round | main tok/round | tile
acc rate | main acc rate | tile prefill tok/s | main prefill tok/s |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| all | 32 | 3912 / 368.8 | 3406 / 252.7 | 10.61 | 13.48 | **0.787** |
0.779–0.795 | 0.791 (n=30) | - | - | - | - | 322.4 | 319.8 |
| >=32K | 32 | 3912 / 368.8 | 3406 / 252.7 | 10.61 | 13.48 | **0.787** |
0.779–0.795 | 0.791 (n=30) | - | - | - | - | 322.4 | 319.8 |
| <32K | 0 | | | | | | | | | | | | | |
| 32-64K | 32 | 3912 / 368.8 | 3406 / 252.7 | 10.61 | 13.48 | **0.787**
| 0.779–0.795 | 0.791 (n=30) | - | - | - | - | 322.4 | 319.8 |
| 64-128K | 0 | | | | | | | | | | | | | |
| >=128K | 0 | | | | | | | | | | | | | |

~~~
all: branch/main 0.787 (95% CI 0.779-0.795); bar >= 0.75
abba: PASS
~~~

### Parity: drafter on against off, greedy, 69 turns to 228,630 tokens

~~~
equivalence t-d-g vs t-nd-g: 69/69 identical; cache histories equal on
69/69
gap: 0 differing turns of 69
~~~

### projection_kernel = false against main, greedy, 64 turns

~~~
equivalence off-g256 vs main-g256: 64/64 identical; cache histories
equal on 64/64
off-g256: load line draft_block=4, configured block [4], 2061 rounds,
most drafted in one round 3, turn lines over 3 drafted per round: none
off: PASS
~~~

### Tool-loop suite: 8 tasks x 6 prompts, paired by prompt

~~~
main: 48 runs, mean grade 0.975, perfect 44/48, blocks ['4'], task
seconds 1169
branch: 48 runs, mean grade 0.985, perfect 45/48, blocks ['5'], task
seconds 1068
branch runs on the kernel (verify and plain calls, none declined):
48/48; main runs with kernel calls: 0
per task (perfect runs):
  cli_flag                 main 3/6  branch 6/6
  dataclass_from_schema    main 6/6  branch 6/6
  docstring_sweep          main 6/6  branch 6/6
  fix_intervals            main 6/6  branch 6/6
  implement_rpn            main 6/6  branch 6/6
  migrate_config           main 6/6  branch 5/6
  rename_symbol            main 6/6  branch 6/6
  tests_for_slugify        main 5/6  branch 4/6
branch vs main over 48 (task, prompt) pairs: main-perfect/branch-not 2,
branch-perfect/main-not 3; one-sided exact McNemar p = 0.8125 -> no harm
detected
~~~

# Suite: failing diffs, branch imperfect runs against main on the same
prompt

- migrate_config, seed 5005: branch 0.67 (failed
test_load_reads_the_json_not_the_ini) - wrote all three JSON files
correctly but rewrote `load` as `CONFIG_DIR.open(f"{name}.json")`, which
passes the file name as Path.open's mode argument, so every load raises;
its one check command was denied by the allowlist and it finished
unverified. Main on the same prompt: 1.00 (3/3), `json.loads((CONFIG_DIR
/ f"{name}.json").read_text())`, no failure.
- tests_for_slugify, seed 5000: branch 0.80 (caught 4/5 mutants; missed
"a dash the cut leaves is kept") - its trailing-dash test `slugify("abc
de", max_length=5) == "abc-d"` cuts on a letter, so no dash is ever left
to remove and the test is vacuous. Main on the same prompt: 1.00 (5/5),
`slugify("Hello World", max_length=6) == "hello"` cuts on the dash.
- tests_for_slugify, seed 5004: branch 0.80 (caught 4/5 mutants; missed
"a dash the cut leaves is kept") - its trailing-dash test
`slugify("abcde fghij", max_length=5) == "abcde"` cuts just before the
dash, so the test is vacuous. Main on the same prompt: 0.80 (4/5), the
same mutant missed for the same reason: `slugify("ab " * 30,
max_length=40)` cuts on a letter ("...ab-a").

### Kernel timings: in-tree against the spike, ms per call and per
forward

| key | T | tree ms | spike ms | A/A gap | tree / spike | band | tree ==
spike | cell |
|---|---|---|---|---|---|---|---|---|
| q+k+v | 1 | 0.2358 | 0.2360 | 0.2% | 0.999 | ±3.0% | True | ok |
| q+k+v | 2 | 0.2445 | 0.2417 | 0.9% | 1.012 | ±3.0% | True | ok |
| q+k+v | 3 | 0.2431 | 0.2437 | 0.7% | 0.998 | ±3.0% | True | ok |
| q+k+v | 4 | 0.2441 | 0.2428 | 0.2% | 1.005 | ±3.0% | True | ok |
| q+k+v | 5 | 0.2456 | 0.2464 | 0.6% | 0.997 | ±3.0% | True | ok |
| q+k+v | 6 | 0.2431 | 0.2449 | 0.1% | 0.993 | ±3.0% | True | ok |
| q+k+v | 7 | 0.2422 | 0.2412 | 0.5% | 1.004 | ±3.0% | True | ok |
| q+k+v | 8 | 0.2428 | 0.2442 | 0.1% | 0.994 | ±3.0% | True | ok |
| gate+up | 1 | 0.4629 | 0.4635 | 0.1% | 0.999 | ±3.0% | True | ok |
| gate+up | 2 | 0.4817 | 0.4816 | 0.1% | 1.000 | ±3.0% | True | ok |
| gate+up | 3 | 0.4842 | 0.4846 | 0.9% | 0.999 | ±3.0% | True | ok |
| gate+up | 4 | 0.4851 | 0.4849 | 0.1% | 1.000 | ±3.0% | True | ok |
| gate+up | 5 | 0.4856 | 0.4874 | 0.2% | 0.996 | ±3.0% | True | ok |
| gate+up | 6 | 0.4864 | 0.4858 | 0.1% | 1.001 | ±3.0% | True | ok |
| gate+up | 7 | 0.4800 | 0.4793 | 0.1% | 1.001 | ±3.0% | True | ok |
| gate+up | 8 | 0.4790 | 0.4784 | 0.3% | 1.001 | ±3.0% | True | ok |
| qkv+z+b+a | 1 | 0.2565 | 0.2566 | 0.2% | 0.999 | ±3.0% | True | ok |
| qkv+z+b+a | 2 | 0.2658 | 0.2654 | 0.1% | 1.002 | ±3.0% | True | ok |
| qkv+z+b+a | 3 | 0.2686 | 0.2672 | 0.3% | 1.005 | ±3.0% | True | ok |
| qkv+z+b+a | 4 | 0.2692 | 0.2686 | 0.1% | 1.002 | ±3.0% | True | ok |
| qkv+z+b+a | 5 | 0.2698 | 0.2687 | 0.0% | 1.004 | ±3.0% | True | ok |
| qkv+z+b+a | 6 | 0.2712 | 0.2702 | 0.3% | 1.004 | ±3.0% | True | ok |
| qkv+z+b+a | 7 | 0.2670 | 0.2658 | 0.7% | 1.004 | ±3.0% | True | ok |
| qkv+z+b+a | 8 | 0.2684 | 0.2681 | 0.2% | 1.001 | ±3.0% | True | ok |
| o/out_proj | 1 | 0.0922 | 0.0925 | 0.2% | 0.996 | ±3.0% | True | ok |
| o/out_proj | 2 | 0.0953 | 0.0964 | 0.6% | 0.988 | ±3.0% | True | ok |
| o/out_proj | 3 | 0.0964 | 0.0965 | 0.3% | 0.999 | ±3.0% | True | ok |
| o/out_proj | 4 | 0.0965 | 0.0965 | 0.1% | 1.000 | ±3.0% | True | ok |
| o/out_proj | 5 | 0.0967 | 0.0967 | 0.6% | 0.999 | ±3.0% | True | ok |
| o/out_proj | 6 | 0.0970 | 0.0967 | 0.2% | 1.003 | ±3.0% | True | ok |
| o/out_proj | 7 | 0.0950 | 0.0963 | 0.3% | 0.986 | ±3.0% | True | ok |
| o/out_proj | 8 | 0.0957 | 0.0955 | 0.1% | 1.002 | ±3.0% | True | ok |
| down | 1 | 0.2454 | 0.2456 | 0.6% | 0.999 | ±3.0% | True | ok |
| down | 2 | 0.2533 | 0.2539 | 0.1% | 0.998 | ±3.0% | True | ok |
| down | 3 | 0.2542 | 0.2549 | 0.3% | 0.997 | ±3.0% | True | ok |
| down | 4 | 0.2551 | 0.2548 | 0.3% | 1.001 | ±3.0% | True | ok |
| down | 5 | 0.2550 | 0.2552 | 0.5% | 0.999 | ±3.0% | True | ok |
| down | 6 | 0.2562 | 0.2560 | 0.4% | 1.001 | ±3.0% | True | ok |
| down | 7 | 0.2531 | 0.2541 | 0.2% | 0.996 | ±3.0% | True | ok |
| down | 8 | 0.2525 | 0.2530 | 0.3% | 0.998 | ±3.0% | True | ok |
| lm_head | 1 | 2.8904 | 2.8867 | 0.2% | 1.001 | ±3.0% | True | ok |
| lm_head | 2 | 2.9661 | 3.0261 | 0.0% | 0.980 | ±3.0% | True | ok |
| lm_head | 3 | 2.9841 | 3.0124 | 0.0% | 0.991 | ±3.0% | True | ok |
| lm_head | 4 | 2.9572 | 2.9605 | 0.2% | 0.999 | ±3.0% | True | ok |
| lm_head | 5 | 2.9579 | 2.9594 | 0.1% | 1.000 | ±3.0% | True | ok |
| lm_head | 6 | 2.9636 | 2.9611 | 0.3% | 1.001 | ±3.0% | True | ok |
| lm_head | 7 | 2.9394 | 2.9299 | 0.1% | 1.003 | ±3.0% | True | ok |
| lm_head | 8 | 2.9097 | 2.9086 | 0.1% | 1.000 | ±3.0% | True | ok |
| q | 1 | 0.1955 | 0.1965 | 1.1% | 0.995 | ±3.0% | True | ok |
| q | 2 | 0.2035 | 0.2028 | 0.3% | 1.004 | ±3.0% | True | ok |
| q | 3 | 0.2024 | 0.2029 | 0.2% | 0.998 | ±3.0% | True | ok |
| q | 4 | 0.2040 | 0.2028 | 0.0% | 1.006 | ±3.0% | True | ok |
| q | 5 | 0.2054 | 0.2053 | 0.5% | 1.001 | ±3.0% | True | ok |
| q | 6 | 0.2053 | 0.2057 | 0.4% | 0.998 | ±3.0% | True | ok |
| q | 7 | 0.2032 | 0.2037 | 0.4% | 0.998 | ±3.0% | True | ok |
| q | 8 | 0.2035 | 0.2040 | 0.2% | 0.997 | ±3.0% | True | ok |
| k/v | 1 | 0.0243 | 0.0251 | 0.1% | 0.970 | ±3.0% | True | FAIL |
| k/v | 2 | 0.0249 | 0.0257 | 0.3% | 0.970 | ±3.0% | True | ok |
| k/v | 3 | 0.0251 | 0.0258 | 0.3% | 0.973 | ±3.0% | True | ok |
| k/v | 4 | 0.0251 | 0.0258 | 0.1% | 0.975 | ±3.0% | True | ok |
| k/v | 5 | 0.0252 | 0.0259 | 0.2% | 0.975 | ±3.0% | True | ok |
| k/v | 6 | 0.0253 | 0.0259 | 0.2% | 0.976 | ±3.0% | True | ok |
| k/v | 7 | 0.0249 | 0.0256 | 0.1% | 0.976 | ±3.0% | True | ok |
| k/v | 8 | 0.0251 | 0.0257 | 0.3% | 0.975 | ±3.0% | True | ok |
| gate/up | 1 | 0.2606 | 0.2608 | 0.0% | 0.999 | ±3.0% | True | ok |
| gate/up | 2 | 0.2694 | 0.2702 | 0.0% | 0.997 | ±3.0% | True | ok |
| gate/up | 3 | 0.2710 | 0.2718 | 0.1% | 0.997 | ±3.0% | True | ok |
| gate/up | 4 | 0.2716 | 0.2714 | 0.1% | 1.001 | ±3.0% | True | ok |
| gate/up | 5 | 0.2722 | 0.2725 | 0.0% | 0.999 | ±3.0% | True | ok |
| gate/up | 6 | 0.2734 | 0.2735 | 0.3% | 1.000 | ±3.0% | True | ok |
| gate/up | 7 | 0.2690 | 0.2690 | 0.0% | 1.000 | ±3.0% | True | ok |
| gate/up | 8 | 0.2714 | 0.2727 | 0.2% | 0.995 | ±3.0% | True | ok |
| in_proj_qkv | 1 | 0.1694 | 0.1697 | 0.5% | 0.998 | ±3.0% | True | ok |
| in_proj_qkv | 2 | 0.1720 | 0.1737 | 1.0% | 0.990 | ±3.0% | True | ok |
| in_proj_qkv | 3 | 0.1715 | 0.1716 | 0.2% | 1.000 | ±3.0% | True | ok |
| in_proj_qkv | 4 | 0.1737 | 0.1753 | 0.2% | 0.991 | ±3.0% | True | ok |
| in_proj_qkv | 5 | 0.1768 | 0.1765 | 0.4% | 1.002 | ±3.0% | True | ok |
| in_proj_qkv | 6 | 0.1750 | 0.1761 | 0.1% | 0.994 | ±3.0% | True | ok |
| in_proj_qkv | 7 | 0.1751 | 0.1754 | 0.2% | 0.998 | ±3.0% | True | ok |
| in_proj_qkv | 8 | 0.1754 | 0.1753 | 0.4% | 1.001 | ±3.0% | True | ok |
| z | 1 | 0.1071 | 0.1074 | 0.1% | 0.998 | ±3.0% | True | ok |
| z | 2 | 0.1078 | 0.1086 | 0.1% | 0.992 | ±3.0% | True | ok |
| z | 3 | 0.1106 | 0.1105 | 0.0% | 1.001 | ±3.0% | True | ok |
| z | 4 | 0.1102 | 0.1106 | 0.1% | 0.996 | ±3.0% | True | ok |
| z | 5 | 0.1106 | 0.1112 | 0.2% | 0.995 | ±3.0% | True | ok |
| z | 6 | 0.1104 | 0.1106 | 0.2% | 0.998 | ±3.0% | True | ok |
| z | 7 | 0.1096 | 0.1098 | 0.0% | 0.998 | ±3.0% | True | ok |
| z | 8 | 0.1088 | 0.1093 | 0.0% | 0.995 | ±3.0% | True | ok |
| b/a | 1 | 0.0205 | 0.0210 | 0.5% | 0.975 | ±3.0% | True | ok |
| b/a | 2 | 0.0216 | 0.0219 | 0.1% | 0.988 | ±3.0% | True | ok |
| b/a | 3 | 0.0219 | 0.0223 | 0.1% | 0.979 | ±3.0% | True | ok |
| b/a | 4 | 0.0225 | 0.0228 | 0.2% | 0.987 | ±3.0% | True | ok |
| b/a | 5 | 0.0226 | 0.0231 | 0.4% | 0.982 | ±3.0% | True | ok |
| b/a | 6 | 0.0228 | 0.0232 | 0.4% | 0.982 | ±3.0% | True | ok |
| b/a | 7 | 0.0225 | 0.0228 | 0.2% | 0.986 | ±3.0% | True | ok |
| b/a | 8 | 0.0231 | 0.0236 | 0.0% | 0.976 | ±3.0% | True | ok |
| T | tree ms / forward | spike ms / forward | #133 | tree / #133 | tree
/ spike | forward |
|---|---|---|---|---|---|---|
| 1 | 75.18 | 75.47 | 75.00 | 1.002 | 0.996 | ok |
| 2 | 77.95 | 77.95 | 77.16 | 1.010 | 1.000 | ok |
| 3 | 79.62 | 78.30 | 78.55 | 1.014 | 1.017 | ok |
| 4 | 78.74 | 78.19 | 78.12 | 1.008 | 1.007 | ok |
| 5 | 78.63 | 78.71 | 78.22 | 1.005 | 0.999 | ok |
| 6 | 78.46 | 78.47 | 77.24 | 1.016 | 1.000 | ok |
| 7 | 77.74 | 77.61 | 78.20 | 0.994 | 1.002 | ok |
| 8 | 78.44 | 78.49 | 78.92 | 0.994 | 0.999 | ok |
ktime FAIL {'cells': 1}

### M2 Air (9B + DFlash, the #143 task set)

~~~
HTTP errors: 0
greedy replies identical on 12/12 turns
branch load line: sous.engine: model_load seconds=11.5
model=mlx-community/Qwen3.5-9B-MLX-4bit positions=engine
verify_attention=active verify_attention_probe_s=0.26
draft_context=active draft_context_window=4095
attention_tile=unavailable projection_kernel=unavailable draft_block=4
branch projection_kernel: {'state': 'unavailable', 'reason': 'macOS 15.5
< 26.2'}; attention_tile: {'state': 'unavailable', 'reason': 'macOS 15.5
< 26.2'}
branch turns over 3 drafted per round: none
m2: PASS
~~~

`scripts/api_smoke.py`: M5 `PASS: a tool_use block came back`, M2 `PASS:
a tool_use block came back`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
krcm0209 added a commit that referenced this pull request Oct 4, 2026
## What and why

#147 moved the default verify block from 3 to 4 on every Mac, from
measurements on the M5 Pro only (#118). On the M2 that is a 3.8x decode
loss: mlx-vlm's exact verifier collapses there from 4 rows, where on the
M5 Pro its knee is at 6 (#156).

An unset `[model].speculative_block_size` now resolves at load by what
is active:
- **5** where the projection kernel is active (unchanged from #155);
- **4** where only the attention tile is active, which is the M5 Pro
with `projection_kernel = false`, where #118 measured block 4;
- **3** everywhere else: M1–M4, older macOS and other models. This was
the default before #147.

An explicit value, 0 included, keeps winning.

- `config.SPECULATIVE_BLOCK_DEFAULT` is now 3. `SPECULATIVE_BLOCK_TILE =
4` sits beside `SPECULATIVE_BLOCK_KERNEL = 5`.
- `tileattn.static_reason()` holds the tile's static half: the switch,
the platform rule, the core count's split target, the model type, the
attention shape and the drafter kind. `projkernel.static_reason()` calls
it and adds its own checks, with its messages unchanged.
- `sous tune`'s `arms.resolve_block` marks the current arm at 5, 4 or 3
by the same rule, and its printed line names the tile case.
- Docs: `CLAUDE.md`, `docs/configuration.md`, `docs/tuning.md` and
`docs/observability.md`.

No release carries #147; it landed after v0.7.0, so this fixes it before
one does.

## Measured

**M2 Air** (8-core GPU, macOS 15.5). The task set is #143's M2 one:
Qwen3.5-9B 4-bit with its DFlash drafter, 12 real turns, greedy,
max_tokens 512. Same harness throughout.

| tree | block | wall clock | decode tok/s | replies |
|---|---|---|---|---|
| main a9fa677 | 4 (default) | 1,083 s | 3.56 | — |
| main a9fa677 | 3 (explicit) | 391 s | 13.46 | 12/12 identical to block
4 |
| this branch | 3 (default; load line `draft_block=3`) | 400 s | 13.05 |
12/12 identical to both |

Each run emitted the same 3,311 tokens. Replies are compared with
tool-use ids stripped.

**M5 Pro**, the branch's load timings (the daemon stayed idle
throughout):

~~~
loadtime mode=plain enable_s=0.194 state=active reason=None probe_s=0.19
draft_block=5 load_s=2.94
loadtime mode=off enable_s=0.000 state=off reason=None probe_s=None
draft_block=4 load_s=2.21
loadtime mode=cold enable_s=3.402 state=active reason=None probe_s=3.4
draft_block=5 load_s=5.62
loadtime mode=warm enable_s=0.192 state=active reason=None probe_s=0.18
draft_block=5 load_s=2.46
~~~

The kernel still gives block 5. With `projection_kernel = false` the
tile gives block 4.

**Tests.** On the M2, `uv run pytest -m "not model"` gives 2095 passed,
39 skipped; ruff, ty and the lockfile are clean. New tests cover:
- the engine's three-way resolution, with explicit values winning and
no-drafter loads untouched;
- the config default and its fallback for an invalid value;
- `tileattn.static_reason`'s refusals;
- `resolve_block`'s tile case.

Closes #156.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
krcm0209 added a commit that referenced this pull request Oct 7, 2026
Closes #87.

`sous tune`'s full run no longer adds a greedy winner-stage arm or
proposes `temperature = 0`. Greedy now runs only when the user sets
`temperature = 0` themselves.

**Why**
- **Greedy has no way out of a repetition loop.** In #145's merge gate,
greedy looped to the token cap on one real subagent turn in all 3 of its
runs on the attention tile. No sampled run looped.
- **The suite cannot see that risk.** On the fixed suite (#162) a greedy
arm draws nothing, so its runs of a task repeat one trajectory. That
leaves one sample per task.
- **The gain is small.** On real subagent turns greedy decoded at most
about 5% faster than sampled (#143, #145).

**What changes**
- `arms.winner_stage_arms` builds only the INT8 prefill arm. `decide`
never writes `temperature`.
- Every arm still inherits the user's temperature, and `Arm.greedy`
still keys suite rows. A user who set `temperature = 0` has every arm
run greedy, and the proposal leaves the setting alone.
- `docs/tuning.md` now describes one winner-stage arm, and both docs say
the tune never proposes greedy.

**Tests**
- The arms tests assert that no winner gets a greedy arm, and that a
winner the user set greedy keeps greedy on its int8 arm.
- A full-run test, parametrized over 0.7 and 0, asserts that no graded
arm changes the sampler and that the diff never mentions `temperature`.
- `uv run pytest -m "not model"`: 2274 passed. ty, ruff and `uv lock
--check` are clean.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

engine: hand the DFlash2 drafter the prompt's hidden states on the hybrid prompt-cache path

2 participants